package myjava;

import java.io.Console;
import java.util.Scanner;

import static java.lang.Thread.sleep;

public class Main {

    public static void main(String[] args) {
	// write your code here




    //    jiayou j =new jiayou();
    //    j.jiayou(j.rongliang(),j.shengyou());



   set_passwd p= new set_passwd();
   p.set_passwds();



    }
}



// 输入油箱容量，与剩余油量，模拟加油过程*************************************************
class jiayou{
    public static float rongliang(){
        System.out.println("请输入油箱总容量： （L）");
        Scanner sc = new Scanner(System.in);
        float youxiang=sc.nextFloat();
        return youxiang;
    }
    public static float shengyou(){
        System.out.println("请输入剩余油量： （L）");
        Scanner sc = new Scanner(System.in);
        float shengyu=sc.nextFloat();
        return shengyu;
    }
    public void jiayou(float a, float b){
        float x =a-b; //所需加油量
        int t=0;
        while(true){
        float now_you=b*100/a;
            System.out.print("加油进度：");
        for (int i=1; i<=now_you;i++){
            System.out.print("█");
        }
        for (int j=1; j<=100-now_you;j++){
            System.out.print("∷");
        }
            System.out.print("   ，进度："+ (float)(Math.round(b/a*100*100))/100+"%");
            System.out.println(" ");
        try {
            sleep(1000);
        }
        catch(InterruptedException e)
        {
            e.printStackTrace();
        }

            b=b+0.4f;
        t++;

        if (b>=a){
            System.out.println("加油完成,用时"+t+"秒。");
            break;

        }
        }

    }

}

class credit_card_pw{
    String passwd;
    public credit_card_pw(String passwd){
        this.passwd= passwd;
    }
    public credit_card_pw(){
        this("123456");
    }
}



//***********************设置密码，默认123456
class set_passwd{
    public void set_passwds(){


    while (true) {

        System.out.print("plz.input a passwd:");
        Scanner input_pwd =new Scanner(System.in);
        String pwd=input_pwd.nextLine();

        System.out.print("plz.input a passwd again:");
        Scanner input_pwd2 =new Scanner(System.in);
        String pwd2=input_pwd2.nextLine();


/*
        System.out.println("plz.input a passwd:");
        Console con1 =System.console();
        pwd=con1.readPassword();
        System.out.println("plz.input a passwd again:");
        Console con2 =System.console();
        pwd2=con2.readPassword();

 */

     //   System.out.println("pwd="+pwd);
     //   System.out.println("pwd2="+pwd2);
        if (pwd.equals(pwd2)) {
           // System.out.println(" 2 input match is called!");
            if (pwd.length() !=0 ) {
                credit_card_pw pwds1 = new credit_card_pw(String.valueOf(pwd));
                System.out.println("pwd is " + pwds1.passwd);
                break;
            } else {
                credit_card_pw pwds2 = new credit_card_pw();
                System.out.println("pwd is " + pwds2.passwd);
                break;
            }
        }

    }
    }

}